<template>
  <div class="gover_all">
    <div v-if="statusNum === 1">
      <h2>物业服务项目经营收支情况报告</h2>
      <div class="introduction">
        <h3>尊敬的全体业主：</h3>
        <p>本小区（大厦）根据省、市《物业管理条例》及《小区公共收益管理与使用办法》等法律法规有关规定。
          小区共用部位、共用设施设备经营性收支情况，为更好接受全体业主的监督，将收支情况予以公布如下：</p>
        <h4>单位：元</h4>
      </div>
      <div class="form_box">
        <div class="thead_title">
          <span>共用部位、共用设施设备经营支出</span>
        </div>
        <table class="table">
          <thead>
          <tr>
            <th>时间</th>
            <th>收入</th>
            <th>支出</th>
            <th>余额</th>
            <th>明细</th>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td><span>本月收入</span></td>
            <td><span>￥{{month.income}}</span></td>
            <td><span>￥{{month.expenditure}}</span></td>
            <td><span>￥{{month.balance}}</span></td>
            <td class="td_width" @click="$router.push('/home/LookDetail/'+month.type)"><span
              class="only_color">查看</span>
            </td>
          </tr>
          <tr>
            <td><span>本季度收入</span></td>
            <td><span>￥{{quarter.income}}</span></td>
            <td><span>￥{{quarter.expenditure}}</span></td>
            <td><span>￥{{quarter.balance}}</span></td>
            <td class="td_width" @click="$router.push('/home/LookDetail/'+quarter.type)"><span
              class="only_color">查看</span></td>
          </tr>
          <tr>
            <td><span>半年收入</span></td>
            <td><span>￥{{halfYear.income}}</span></td>
            <td><span>￥{{halfYear.expenditure}}</span></td>
            <td><span>￥{{halfYear.balance}}</span></td>
            <td class="td_width" @click="$router.push('/home/LookDetail/'+halfYear.type)"><span
              class="only_color">查看</span></td>
          </tr>
          <tr>
            <td><span>1年收入</span></td>
            <td><span>￥{{year.income}}</span></td>
            <td><span>￥{{year.expenditure}}</span></td>
            <td><span>￥{{year.balance}}</span></td>
            <td class="td_width" @click="$router.push('/home/LookDetail/'+year.type)"><span class="only_color">查看</span>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="form_box2">
        <table class="table">
          <tbody>
          <tr>
            <td><span>历年总余额</span></td>
            <td colspan="3" class="col_3"><span>￥{{total.balance}}</span></td>
            <td class="td_width" @click="$router.push('/home/LookDetail/'+total.type)"><span
              class="only_color">查看</span></td>
          </tr>
          </tbody>
        </table>
      </div>
      <h5>附：其他应专款专用的经费收支情况</h5>
    </div>
    <div class="default2" v-if="statusNum === 0">
      <p>对不起您不是该小区业主，或者去我的房申请进行审核</p>
    </div>
    <popup-view :isShow="showPopup" :desc="desc" @goCancel="btnCancel" @goIdent="btnIndent"></popup-view>
  </div>
</template>
<style lang="scss" scoped>
  .gover_all {
    width: 100%;
    padding-top: 48px;
    h2 {
      width: 100%;
      line-height: 50px;
      font-size: 16px;
      text-align: center;
    }
    .introduction {
      width: 100%;
      h3 {
        font-size: 15px;
        font-weight: normal;
        padding: 10px;
      }
      p {
        font-size: 15px;
        line-height: 25px;
        padding: 0 10px 10px 10px;
      }
      h4 {
        font-size: 15px;
        font-weight: normal;
        float: right;
        padding-right: 10px;
      }
    }
    .form_box {
      width: 98%;
      margin-left: 0.8%;
      margin-top: 30px;
      border: 1px solid #d7d7d7;
      .thead_title {
        width: 100%;
        text-align: center;
        line-height: 40px;
        border-bottom: 1px solid #d7d7d7;
        span {
          font-size: 14px;
        }
      }
      .table {
        width: 100%;
        line-height: 30px;
        text-align: center;
        table-layout: fixed;
        thead {
          tr {
            th {
              width: 20%;
              border-bottom: 1px solid #d7d7d7;
              font-size: 14px;
              font-weight: normal;
              border-right: 1px solid #d7d7d7;
            }
            th:last-child {
              border-right: none;
            }
          }
        }
        tbody {
          tr {
            border-bottom: 1px solid #d7d7d7;
            td {
              font-size: 12px;
              color: #393939;
              font-weight: normal;
              border-right: 1px solid #d7d7d7;
              vertical-align: middle;
              width: 20%;
              word-wrap: break-word;
              word-break: break-all;
              span {
                color: #393939;
              }
              .only_color {
                color: #0b7ad9;
              }
            }
            .only_color {
              color: #0b7ad9;
            }
            td:last-child {
              border-right: none;
            }
          }
          tr:last-child {
            border-bottom: none;
          }
        }
      }
    }
    /*有合并的表格样式*/
    .form_box2 {
      width: 98%;
      margin-left: 0.8%;
      border: 1px solid #d7d7d7;
      border-top: none;
      .table {
        width: 100%;
        line-height: 30px;
        text-align: center;
        table-layout: fixed;
        tbody {
          tr {
            border-bottom: 1px solid #d7d7d7;
            td {
              font-size: 12px;
              color: #393939;
              font-weight: normal;
              border-right: 1px solid #d7d7d7;
              vertical-align: middle;
              width: 20%;
              word-wrap: break-word;
              word-break: break-all;
            }
            .col_3 {
              text-align: left;
              padding-left: 22px;
              width: 60%;
            }
            .only_color {
              color: #0b7ad9;
            }
            td:last-child {
              border-right: none;
            }
          }
          tr:last-child {
            border-bottom: none;
          }
        }
      }
    }
    h5 {
      padding: 10px;
      font-size: 15px;
      font-weight: normal;
    }
    .default2 {
      width: 100%;
      flex: 1;
      display: inline-flex;
      padding-top: 100px;
      justify-content: center;
      align-items: center;
      padding-bottom: 100px;
      p {
        font-size: 15px;
        color: #292929;
        margin-top: 100px;
      }
    }
  }
</style>
<script>
  import {getGoverAll} from '../../api/government'
  import {getMangers} from '../../api/management'
  import {loadPhoneName} from '../../common/js/cache'
  import popupView from '../common/popupView'

  export default {
    name: 'GoverAll',
    data() {
      return {
        month: {},
        quarter: {},
        halfYear: {},
        year: {},
        total: {},
        statusNum: '',
        loadPhoneName: loadPhoneName(),
        showPopup: false,
        desc: '请先房屋认证'
      }
    },
    created() {
      if (this.loadPhoneName === undefined) {
        this.showPopup = true
      } else {
        if ((loadPhoneName().phone === '0' || loadPhoneName().phone === '') || loadPhoneName().name === '') {
          this.showPopup = true
        } else {
          this._getMangers()
        }
      }
      // this._getMangers()
    },
    methods: {
      _getMangers() {
        getMangers().then(res => {
          if (res.code === 200) {
            this.statusNum = res.data.status
            if (this.statusNum !== 0) {
              this._getGoverAll()
            } else {
              this.showPopup = true
            }
          }
        })
      },
      _getGoverAll() {
        getGoverAll().then(res => {
          // console.log(res)
          if (res.code === 200) {
            this.month = res.data.month  // 月
            this.quarter = res.data.quarter // 本季度
            this.halfYear = res.data.halfYear // 半年
            this.year = res.data.year // 年
            this.total = res.data.total // 总共
          }
        })
      },
      // 弹窗取消按钮
      btnCancel() {
        this.showPopup = false
      },
      // 弹窗去认证按钮
      btnIndent() {
        this.$router.push('/my/HouseConfirm')
      }
    },
    components: {
      popupView
    }
  }
</script>
